package com.liunian.algorithmstudy.tree;

public class MinDepth111 extends TreeNode {

	public int minDepth(TreeNode root) {
		if (root == null) {
			return 0;
		}
		int leftDepth = minDepth(root.left);
		int rightDepth = minDepth(root.right);
		if (leftDepth == 0) {
			leftDepth = rightDepth;
		}
		if (rightDepth == 0) {
			rightDepth = leftDepth;
		}
		return Math.min(leftDepth, rightDepth) + 1;
	}

}
